package com.mp.approvalreq.servlet.redpoint;

import com.mp.approvalreq.service.ApprovalOperateServicePrx;
import com.mp.approvalreq.servlet.AbstractServlet;
import com.mp.approvalreq.util.ServiceUtils;
import com.mp.user.entity.User;
import com.plusmoney.message.Message;
import com.plusmoney.message.SuccessMsg;
import com.plusmoney.util.ParameterUtils;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/removeApproverRedpoint")
public class RemoveApproverRedpoint extends AbstractServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            User user = getReqUser(req);
            Integer type = ParameterUtils.getIntegerParameter(req, "type", true);

            ApprovalOperateServicePrx approvalOperateService = ServiceUtils.getApprovalOperateServicePrx();
            approvalOperateService.removeApproverRedpoint(user, type);

            Message.printJson(resp, SuccessMsg.getDefaultMsg());
        } catch (Throwable e) {
            onThrowable(req, resp, e);
        }
    }
}
